package com.future.mayi.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.future.mayi.R;
import com.future.mayi.model.IndexIconModel;
import com.future.mayi.view.RadiusImageView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class IndexRecommendAdapter2 extends BaseRecyclerViewAdapter<IndexIconModel>{

    public IndexRecommendAdapter2(Context context, List<IndexIconModel> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return  new ItemViewHolder(getView(parent, R.layout.item_index_recommend2));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ItemViewHolder viewHolder = (ItemViewHolder) holder;
        IndexIconModel model = getItem(position);
        loadImg(viewHolder.ivImg, model.getIcon_img());
        viewHolder.tvName.setText(model.getIcon_title());
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mOnItemClickListener.OnItem(view, position);
            }
        });
    }

    class ItemViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_bg)
        RadiusImageView ivImg;
        @BindView(R.id.tv_icon_name)
        TextView tvName;

        public ItemViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
